using System;
using System.Runtime.InteropServices;
using LuaCSharpFunction;
namespace Lua4Mono
{
	/// <summary>
	/// Pseudo_ indices.伪指数
	/// </summary>
	public enum PSEUDO_INDICES
	{
		LUA_REGISTRYINDEX 	= 	-10000,
		LUA_ENVIRONINDEX	=	-10001,
		LUA_GLOBALSINDEX	=	-10002
	}
	
	/// <summary>
	/// 线程执行状态
	/// </summary>
	public enum THREAD_STATUS
	{
		/// <summary>
		/// 执行正常无错
		/// </summary>
		LUA_OK 			=	0,
		
		/// <summary>
		/// 让先
		/// </summary>
		LUA_YIELD		=	1,
		
		/// <summary>
		/// 执行错误
		/// </summary>
		LUA_ERRRUN		=	2,
		
		/// <summary>
		/// 语法错误
		/// </summary>
		LUA_ERRSYNTAX	=	3,
		
		/// <summary>
		/// 内存错误
		/// </summary>
		LUA_ERRMEM		=	4,
		
		/// <summary>
		/// 异常处理出错
		/// </summary>
		LUA_ERRERR		=	5
	}
	
	/// <summary>
	/// lua常量
	/// </summary>
	public enum LUA_CONST
	{
		/// <summary>
		/// pcall和call 返回多个值
		/// </summary>
		LUA_MULTRET = -1
	}
	
	/// <summary>
	/// Lua数据类型
	/// </summary>
	public enum LUA_TYPES
	{
		/// <summary>
		/// 空
		/// </summary>
		LUA_TONOE			=	-1,
		
		/// <summary>
		///  lua的nil
		/// </summary>
		LUA_TNIL			=	0,
		
		/// <summary>
		/// 布尔值
		/// </summary>
		LUA_TBOOLEAN		=	1,
		
		/// <summary>
		/// 轻型用户数据
		/// </summary>
		LUA_TLIGHTUSERDATA	=	2,
		
		/// <summary>
		/// 数字型(double)
		/// </summary>
		LUA_TNUMBER			=	3,
		
		/// <summary>
		/// 字符串
		/// </summary>
		LUA_TSTRING			=	4,
		
		/// <summary>
		/// lua的表结构
		/// </summary>
		LUA_TTABLE			=	5,
		
		/// <summary>
		/// 函数/方法
		/// </summary>
		LUA_TFUNCTION		=	6,
		
		/// <summary>
		/// 用户类型
		/// </summary>
		LUA_TUSERDATA		=	7,
		
		/// <summary>
		/// 线程类型
		/// </summary>
		LUA_TTHREAD			=	8
	}
	
	/// <summary>
	/// lua的gc状态
	/// </summary>
	public enum LUA_GC
	{
		LUA_GCSTOP		=	0,
		LUA_GCRESTART	=	1,
		LUA_GCCOLLECT	=	2,
		LUA_GCCOUNT		=	3,
		LUA_GCCOUNTB	=	4,
		LUA_GCSTEP		=	5,
		LUA_GCSETPAUSE	=	6,
		LUA_GCSETSTEPMUL=	7
	}
	
	public class luaDLL
	{
		public const string FileName				=	"lua5.1.dll";
		
		public const string LUA_VERSION			= 	"Lua	5.1";
		
		public const int LUA_VERSION_NUM		=	501;
		
		public const string  LUA_COPYRIGHT   	=	"Copyright (C) 1994-2006 Lua.org, PUC-Rio";
		
		public const string LUA_AUTHORS     	=	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes";
	}
	
	public class Lua51
	{
		
		
		#region 状态机操作
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern  IntPtr lua_newstate(IntPtr f,IntPtr ud);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_atpanic(IntPtr L,LuaCSsharpFunction callBack);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_close(IntPtr L);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_newthread(IntPtr L);
		
		#endregion
		
		#region 堆栈操作
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_gettop(IntPtr L);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_settop(IntPtr L,int top);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushvalue(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_remove(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_insert(IntPtr L ,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_replace(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_checkstack(IntPtr L,int size);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_xmove(IntPtr from_L,IntPtr to_L,int n);
		
		#endregion
		
		
		#region 直接访问堆栈的方法
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_isnumber(IntPtr L,int idx);
		
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_isstring(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_iscfunction(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_isuserdata(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern LUA_TYPES lua_type(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern string lua_typename(IntPtr L,LUA_TYPES tp);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_equal(IntPtr L,int idx1,int idx2);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_rawequal(IntPtr L,int idx1,int idx2);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_lessthan(IntPtr L,int idx1,int idx2);
		
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern double  lua_tonumber(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_tointeger(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_toboolean(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr  lua_tolstring(IntPtr L,int idx,out int len);
			
		public static  string lua_tostring(IntPtr L,int idx)
		{
			if(lua_isstring(L ,idx)==0)
				return null;
			int len=-1;
			IntPtr pstr = lua_tolstring(L,idx, out len);
			if(pstr != IntPtr .Zero)
				return Marshal.PtrToStringAnsi(pstr,len);
			return null;
		}
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_objlen(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern LuaCSsharpFunction lua_tocfunction(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_touserdata(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_tothread(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_topointer(IntPtr L,int idx);
		
		
		#endregion
		
		
		#region push方法
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushnil(IntPtr L);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushnumber(IntPtr L,double n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushinteger(IntPtr L,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushlstring(IntPtr L,string s,int l);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushstring(IntPtr L,string s);
		
//		LUA_API const char *(lua_pushvfstring) (lua_L *L, const char *fmt,
//                                                      va_list argp);
//		LUA_API const char *(lua_pushfstring) (lua_L *L, const char *fmt, ...);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushcclosure(IntPtr L,LuaCSsharpFunction fn,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushboolean(IntPtr L,int b);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_pushlightuserdata(IntPtr L,IntPtr p);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_pushthread(IntPtr L);
		
		#endregion
		
		
		#region get方法
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_gettable(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_getfield(IntPtr L,int idx,string k);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_rawget(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_rawgeti(IntPtr L,int idx,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_createtable(IntPtr L,int narr,int nrec);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_createuserdata(IntPtr L,int sz);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_getmetatable(IntPtr L,int objindex);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_getfenv(IntPtr L,int idx);
		
		#endregion 
		
		
		#region set方法
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_settable(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_setfield(IntPtr L,int idx,string k);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_rawset(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_rawseti(IntPtr L,int idx,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_setmetatable(IntPtr L,int objindex);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_setfenv(IntPtr L,int idx);
		
		#endregion
		
		
		#region Load 和call 方法
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_call(IntPtr L,int nargs,int nresults);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_pcall(IntPtr L,int nargs,int nresults,int errfun);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_cpcall(IntPtr L,LuaCSsharpFunction func,IntPtr ud);
		
//		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
//		public static extern int lua_load
		
		#endregion
		
		
		
		#region GC方法
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_gc(IntPtr L,int what,int data);
		
		
		#endregion
		
		
		#region 杂项
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_error(IntPtr L);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int lua_next(IntPtr L,int idx);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_concat(IntPtr L,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr lua_getallocf(IntPtr L,IntPtr ud);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void lua_setallocf(IntPtr L,IntPtr f,IntPtr ud);
			
		#endregion
		
		#region debug方法
		//略
		#endregion
		
		#region LuaAuxLib
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_getn(IntPtr L,int t);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_setn(IntPtr L,int t,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_register(IntPtr L,string libname,string l);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_getmetafield(IntPtr L,int obj,string e);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_callmeta(IntPtr L,int obj ,string e);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_typerror(IntPtr L,int nargs,out string tname);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_argerror(IntPtr L,int numargs,out string extramsg);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_checkstack(IntPtr L,int sz,out string msg);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_ref(IntPtr L,int t);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_unref(IntPtr L,int t,int rf);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadfile(IntPtr L,string filename);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadbuffer(IntPtr L,string buff,int sz,string name);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadstring(IntPtr L,string s);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr luaL_newstate();
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_openlibs(IntPtr L);	
		#endregion
		
		#region LuaMacros
		public static void lua_pop(IntPtr L,int count)
		{
			Lua51.lua_settop(L,-count -1);
		}
		
		public static void lua_newtable(IntPtr L)
		{
			Lua51.lua_createtable(L,0,0);
		}
		
		public static void lua_registerfunction(IntPtr L,string n,LuaCSsharpFunction f)
		{
			lua_pushcfunction(L,f);
			lua_setglobal(L,n);
		}
		
		public static void lua_pushcfunction(IntPtr L,LuaCSsharpFunction f)
		{
			Lua51.lua_pushcclosure(L,f,0);
		}
		
		public static void lua_setglobal(IntPtr L,string k)
		{
			Lua51.lua_setfield(L,(int)PSEUDO_INDICES.LUA_GLOBALSINDEX,k);
		}
		
		public static void lua_getglobal(IntPtr L,string k)
		{
			Lua51.lua_getfield(L,(int)PSEUDO_INDICES.LUA_GLOBALSINDEX,k);
		}
		
//		public static string lua_tostring(IntPtr L,int i)
//		{
//			return Lua51.lua_tostring(L,i);
//		}
		
		public static void lua_pushliteral(IntPtr L,string s)
		{
			Lua51.lua_pushlstring(L,s,s.Length);
		}
		
		public static bool lua_isX(IntPtr L,int idx,LUA_TYPES t)
		{
			return Lua51.lua_type(L,idx)==t;
		}
		
		public static bool luaL_dofile(IntPtr L,string filename)
		{
			return (LuaAuxLib.luaL_loadfile(L,filename)==(int)THREAD_STATUS.LUA_OK) &&
			 (Lua51.lua_pcall(L,0,(int)LUA_CONST.LUA_MULTRET,0)==(int)THREAD_STATUS.LUA_OK);
		}
		
		public static bool luaL_dostring(IntPtr L,string s)
		{
			return (LuaAuxLib.luaL_loadstring(L,s)==(int)THREAD_STATUS.LUA_OK )&&
				(Lua51.lua_pcall(L,0,(int)LUA_CONST.LUA_MULTRET,0)==(int)THREAD_STATUS.LUA_OK);
		}
		
		public static void lua_pushboolean(IntPtr L,bool b)
		{
			if(b)
				Lua51.lua_pushboolean(L,1);
			else
				Lua51.lua_pushboolean(L,0);
		}
		#endregion
	}
	
	
	/// <summary>
	/// lua的宏
	/// </summary>
	public class LuaMacros
	{
		public static void lua_pop(IntPtr L,int count)
		{
			Lua51.lua_settop(L,-count -1);
		}
		
		public static void lua_newtable(IntPtr L)
		{
			Lua51.lua_createtable(L,0,0);
		}
		
		public static void lua_registerfunction(IntPtr L,string n,LuaCSsharpFunction f)
		{
			lua_pushcfunction(L,f);
			lua_setglobal(L,n);
		}
		
		public static void lua_pushcfunction(IntPtr L,LuaCSsharpFunction f)
		{
			Lua51.lua_pushcclosure(L,f,0);
		}
		
		public static void lua_setglobal(IntPtr L,string k)
		{
			Lua51.lua_setfield(L,(int)PSEUDO_INDICES.LUA_GLOBALSINDEX,k);
		}
		
		public static void lua_getglobal(IntPtr L,string k)
		{
			Lua51.lua_getfield(L,(int)PSEUDO_INDICES.LUA_GLOBALSINDEX,k);
		}
		
		public static string lua_tostring(IntPtr L,int i)
		{
			return Lua51.lua_tostring(L,i);
		}
		
		public static void lua_pushliteral(IntPtr L,string s)
		{
			Lua51.lua_pushlstring(L,s,s.Length);
		}
		
		public static bool lua_isX(IntPtr L,int idx,LUA_TYPES t)
		{
			return Lua51.lua_type(L,idx)==t;
		}
		
		public static bool luaL_dofile(IntPtr L,string filename)
		{
			return (LuaAuxLib.luaL_loadfile(L,filename)==(int)THREAD_STATUS.LUA_OK) &&
			 (Lua51.lua_pcall(L,0,(int)LUA_CONST.LUA_MULTRET,0)==(int)THREAD_STATUS.LUA_OK);
		}
		
		public static bool luaL_dostring(IntPtr L,string s)
		{
			return (LuaAuxLib.luaL_loadstring(L,s)==(int)THREAD_STATUS.LUA_OK )&&
				(Lua51.lua_pcall(L,0,(int)LUA_CONST.LUA_MULTRET,0)==(int)THREAD_STATUS.LUA_OK);
		}
		public static void lua_pushboolean(IntPtr L,bool b)
		{
			if(b)
				Lua51.lua_pushboolean(L,1);
			else
				Lua51.lua_pushboolean(L,0);
		}
	}
	
	public class LuaAuxLib
	{
	
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_getn(IntPtr L,int t);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_setn(IntPtr L,int t,int n);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_register(IntPtr L,string libname,string l);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_getmetafield(IntPtr L,int obj,string e);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_callmeta(IntPtr L,int obj ,string e);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_typerror(IntPtr L,int nargs,out string tname);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_argerror(IntPtr L,int numargs,out string extramsg);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_checkstack(IntPtr L,int sz,out string msg);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_ref(IntPtr L,int t);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_unref(IntPtr L,int t,int rf);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadfile(IntPtr L,string filename);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadbuffer(IntPtr L,string buff,int sz,string name);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern int luaL_loadstring(IntPtr L,string s);
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr luaL_newstate();
		
		[DllImport(luaDLL.FileName,CallingConvention = CallingConvention.Cdecl)]
		public static extern void luaL_openlibs(IntPtr L);	
		
		
	}
	
}

